package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.jdbc.Null;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@JsonIgnoreProperties("handler")
public class StrategyCatalog {
    public static final boolean STATE_NORMAL = true;
    public static final boolean STATE_DISABLE = false;
    private Long id;    //id

    private String name;    //分类名称

    private Strategy strategy;  //所属攻略

    private Integer sequence;   //排序

    private Boolean state;     //状态

    private Long strategyId;   //冗余id

    private List<StrategyDetail> details = new ArrayList<>();

    public String getStateDisplay(){
        if(state == null){
            return "";
        }else if(state == true){
            return "启用";
        }else{
            return "禁用";
        }
    }

    public String getJsonString(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        if (strategy != null) {
            map.put("strategyId",strategy.getId());
        }
        map.put("sequence",sequence);
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }
}